package ihm;

import learning.*;
import javax.swing.JPanel;
import javax.swing.JFrame;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import maze.*;
import perception.*;

/**

 * *************************************
 */
public class MemoryPanel extends javax.swing.JPanel {

    Application _application;
    private static int _viewHigh = 180;
    private static int _viewWidth = 120;

    public MemoryPanel() {
        super();

    }

    public void setApplication(Application app) {
        _application = app;
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        drawMemory(g);
    }

    public void drawMemory(Graphics g) {
        if (_application.getLearner() != null) {
            int stepX = (int) (_viewWidth / _application.getMaze().getLength());
            int stepY = (int) (_viewHigh / _application.getMaze().getHigh());

            for (MemoryPattern mp : _application.getLearner().getMemory()) {
                mp.draw(g, stepX, stepY);
            }
        }
    }
}
